package com.yjx.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yjx.vo.Repair;
import com.yjx.service.RepairService;
import com.yjx.mapper.RepairMapper;
import com.yjx.vo.Tongji;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 10657
* @description 针对表【repair】的数据库操作Service实现
* @createDate 2023-05-11 15:55:36
*/
@Service
public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair>
    implements RepairService{
    @Autowired
    private RepairMapper repairMapper;
    @Override
    public PageInfo<Repair> findRepairAll(Integer page, Integer limit, Repair repair){
        PageHelper.startPage(page,limit);
        List<Repair> list=repairMapper.queryRepairAll(repair);
        PageInfo<Repair> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int add(Repair repair) {
        return baseMapper.insert(repair);
    }

    @Override
    public int delete(Long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public int updateData(Repair repair) {
        return baseMapper.updateById(repair);
    }

    @Override
    public List<Repair> queryList() {
        return repairMapper.queryRepairAll(null);
    }

    @Override
    public Repair findById(Long id){
        return  baseMapper.selectById(id);
    }
    @Override
    public IPage<Repair> findListByPage(Integer page, Integer pageCount){
        IPage<Repair> wherePage = new Page<>(page, pageCount);
        Repair where = new Repair();

        return   baseMapper.selectPage(wherePage, Wrappers.query(where));
    }

    @Override
    public List<Tongji> queryTongji() {
        return repairMapper.queryTongji();
    }
}




